<?php

namespace Modules\Common\General\Notification\Sms;


use Modules\Common\Exceptions\Common\ValidationException;
use Modules\Common\Util\Api;


class SendVerifyCodeController
{

    protected $tags = [
        'admin-login',
        'h5-login',
        'web-login',
    ];


    /**
     * @Route(path=/api/sms/send/{tag})
     */
    public function index(string $tag)
    {
        if (!in_array($tag, $this->tags)) {
            ValidationException::new()
                ->tellUser('路径不存在')
                ->logNotice('路径不存在', ['req' => request()->all()])
                ->throw();
        }
        Api::validate(['mobile' => 'mobile']);
        $sms = new Sms();
        $sms->sendLoginVerify(request('mobile'), $tag);
        return Api::success(null, '发送成功');
    }

}
